package system.util;

/**
 * This implementation is used to <i>Time</i> system
 * <p>
 * {@code void timeStart()} is called when firstly calling {@code void time()}
 * 
 * @author Jack
 * 
 */
public class Timer {
	static private long startTimestamp, lastTimestamp;
	static private boolean started = false;

	static private void timeStart() {
		startTimestamp = System.currentTimeMillis();
		lastTimestamp = startTimestamp;
		started = true;
	}

	/**
	 * Print out elapsed time since last time call {@code void time()} and first
	 * time call {@code void time()}
	 */
	static public void time() {
		if (!started)
			timeStart();
		long now = System.currentTimeMillis();
		System.out.print((now - lastTimestamp) / 1000 + "s since last time;  ");
		System.out.println((now - startTimestamp) / 1000 + "s since begin;  ");
		lastTimestamp = now;
	}
}
